<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /*
    
    */

    const p = new Promise((resolve, reject) => {
      console.log('请求数据');
      //模拟异步请求
      //利用try catch模拟特殊异常 try：尝试代码 如果报错了catch就会介入进行处理 catch:处理异常主要处理特殊异常无法控制
      try {
        //抛出一个错误
        throw new Error('错误')
        setTimeout(() => {
          console.log('成功');
          resolve('1')
        }, 2000)
      } catch (e) { // e就是错误的对象 
       // console.log(e.message); //message属性可以读写详细的错误信息
         reject(e.message)
      }
    })
    console.log('p',p);
  </script>
</body>

</html>